Issue 53498: reject string attachment values for query insert/update api#6928
Merged
Issue 53498: reject string attachment values for query insert/update api#6928
Conversation
| if (isAttachmentProperty(name)) | ||
| { | ||
| if (null != file.getFilename()) | ||
| if (value instanceof AttachmentFile file) |
Contributor
There was a problem hiding this comment.
nit: Put more simply:
if (value instanceof AttachmentFile file)
{
if (null != file.getFilename())
{
rowStripped.put(name, file.getFilename());
attachments.put(name, value);
}
}
else if (value instanceof String strVal && !StringUtils.isEmpty(strVal))
{
// Issue 53498: string value for an attachment field is not allowed
throw new ValidationException("Can't upload '" + strVal + "' to field " + name + " with type Attachment.");
}
else
rowStripped.put(name, value); // if blank, remove the attachment| attachments.put(name, value); | ||
| } | ||
| } | ||
| else if (value instanceof String strVal) |
Contributor
There was a problem hiding this comment.
Does this leave it open to being another type of value besides a File or String (number, date, boolean, etc.)?
Contributor
Author
There was a problem hiding this comment.
Changed made to also check for non string types (excluding attachment type). Similar change is also made for FileLink fields. Tests added for both attachment and filelink.
labkey-nicka
approved these changes
Aug 18, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale
This PR is the follow up work for #6894 that went to 25.7, that made attachment columns rejecting string type values on import. This PR handles attachment value validation for insert/update api.
Related Pull Requests
Changes
Tasks 📍